package com.example.springbootsfzy.controller.lishenao;

import com.example.springbootsfzy.domain.MemberPoints;
import com.example.springbootsfzy.service.lishenao.Member_pointsService;
import com.example.springbootsfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//积分会员表
//操作人员:李深奥
//操作步骤:增删改查
@RestController
@CrossOrigin
public class Member_pointsController {
    @Autowired
    private Member_pointsService memberPointsService;
    //根据id查询积分
    @GetMapping("/selectpointbyid")
    public R selectByPrimaryKey(Long pointId){
        return R.ok(memberPointsService.selectByPrimaryKey(pointId));
    }
    //根据id删除积分
    @DeleteMapping("/deletepointbyid")
    public R deleteByPrimaryKey(Long pointId){
        int i = memberPointsService.deleteByPrimaryKey(pointId);
        if (i>0){
            return R.ok("删除成功");
        }else {
            return R.error("删除失败");
        }
    }
    //新增积分
    @PostMapping("/insertpoint")
    public R insert(@RequestBody MemberPoints record){
        int i = memberPointsService.insert(record);
        if (i>0){
            return R.ok("新增成功");
        }else {
            return R.error("新增失败");
        }
    }
    //修改积分
    @PutMapping("/updatepoint")
    public R updateByPrimaryKey(@RequestBody MemberPoints record){
        int i = memberPointsService.updateByPrimaryKeySelective(record);
        if (i>0){
            return R.ok("修改成功");
        }else {
            return R.error("修改失败");
        }
    }

}
